import httpRequest from '../request/index'

interface UserInfoParam {
    username: string,
    password: string,
    remember: boolean
}
interface FetchUser {
    username: string,
    phone?: string,
    email?: string
}
export const getUserList = () => {
    return httpRequest({
        url: '/user',
        method: 'get',
    })
}

export const userLogin = (data:UserInfoParam) => {
    return httpRequest({
        method: 'post',
        url: '/login',
        data
    })
}

// 用户管理模块
export const getUserInfo = (params:FetchUser) => {  // 查询用户
    return httpRequest({
        url: '/user',
        method: 'get',
        params
    })
}
export const searchUser = (params: FetchUser) => {  // 查询具体的用户
    return httpRequest({
        url: '/user/search',
        method: 'get',
        params
    })
}
export const addUser = (data: any) => {   // 用户添加
    return httpRequest({
        url: '/user',
        method: 'post',
        data
    })
}
export const delUser = (data: any) => {   // 用户删除
    return httpRequest({
        url: '/user',
        method: 'delete',
        data
    })
}
export const updateUser = (data: any) => {   // 用户更新
    return httpRequest({
        url: '/user',
        method: 'put',
        data
    })
}